﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace Q_Link
{
    public partial class frmAddFolder : Form
    {
        frmSettings Settings;

        public frmAddFolder(frmSettings settings)
        {
            InitializeComponent();
            Settings = settings;
        }

        void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        void buttonSave_Click(object sender, EventArgs e)
        {
            addFolder();
            this.Close();
        }

        void textBoxNewFolder_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                addFolder();
                this.Close();
            }
        }

        void addFolder()
        {
            string newFolder = textBoxNewFolder.Text;
            if (newFolder.Length > 3)
            {
                if (Directory.Exists(newFolder))
                {
                    // call appendToConfigFile on frmSettings
                    Settings.addFolder(newFolder);
                }
                else
                {
                    MessageBox.Show("Folder bestaat niet!");
                }
            }
        }
    }
}
